package com.atguigu.gmall.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall.product.IndexFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/index")
public class IndexController {
    @Autowired
    private IndexFeign indexFeign;
    @GetMapping
    public String index(Model model){
        List<JSONObject> categoryList = indexFeign.getIndexCategory();
        System.out.println(categoryList);
        model.addAttribute("categoryList",categoryList);
        return "index";
    }

}
